﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace Demo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            this.Text = "Report Control Demo";
            this.ClientSize = new System.Drawing.Size(950, 600);

            ReportViewer reportViewer = new ReportViewer();

            // Set Processing Mode

            reportViewer.ProcessingMode = ProcessingMode.Local;

            // Set RDL file

            reportViewer.LocalReport.ReportPath = "Report1.rdl";

            // Supply a DataTable corresponding to each report data source

            reportViewer.LocalReport.DataSources.Add(
                new ReportDataSource("Sales", LoadSalesData()));

            // Add the reportviewer to the form

            reportViewer.Dock = DockStyle.Fill;
            this.Controls.Add(reportViewer);

            // Process and render the report

            reportViewer.RefreshReport();
        }

        private DataTable LoadSalesData()
        {
            // Load data from XML file
            DataSet dataSet = new DataSet();
            dataSet.ReadXml("data.xml");
            return dataSet.Tables[0];
        }

 
    }
}
